package com.momo.mapper.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import com.momo.mapper.dataobject.UserDO;
import com.momo.mapper.mapper.UserDOMapper;

/**
* The Table USER.
* 注意:此结构有系统生成,禁止手工修改,以免被覆盖,请通过dalgen生成
* USER
*/
@Repository
public class UserDAO{

    @Autowired
    private UserDOMapper userDOMapper;

    /**
     * desc:插入表:USER.<br/>
     * descSql =  INSERT INTO user( NICKNAME ,PASSWORD ,USERNAME )VALUES( #{nickname,jdbcType=VARCHAR} ,#{password,jdbcType=VARCHAR} ,#{username,jdbcType=VARCHAR} )
     * @param entity entity
     * @return int
     */
    public int insert(UserDO entity){
        return userDOMapper.insert(entity);
    }
    /**
     * desc:更新表:USER.<br/>
     * descSql =  UPDATE USER SET NICKNAME = #{nickname,jdbcType=VARCHAR} ,PASSWORD = #{password,jdbcType=VARCHAR} ,USERNAME = #{username,jdbcType=VARCHAR} WHERE ID = #{id,jdbcType=BIGINT}
     * @param entity entity
     * @return int
     */
    public int update(UserDO entity){
        return userDOMapper.update(entity);
    }
    /**
     * desc:根据主键删除数据:USER.<br/>
     * descSql =  DELETE FROM USER WHERE ID = #{id,jdbcType=BIGINT}
     * @param id id
     * @return int
     */
    public int deleteById(Long id){
        return userDOMapper.deleteById(id);
    }
    /**
     * desc:根据主键获取数据:USER.<br/>
     * descSql =  SELECT * FROM USER WHERE ID = #{id,jdbcType=BIGINT}
     * @param id id
     * @return UserDO
     */
    public UserDO getById(Long id){
        return userDOMapper.getById(id);
    }
    /**
     * desc:根据主键获取数据:USER.<br/>
     * descSql =  SELECT * FROM user WHERE username = #{username,jdbcType=VARCHAR}
     * @param username username
     * @return UserDO
     */
    public UserDO findByUsername(String username){
        return userDOMapper.findByUsername(username);
    }
}
